package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Splc;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.SplcVo;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.ZskXq;
import vip.xiaonuo.smzq.modular.kcl.service.ISplcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 矿山审批流程
 *
 * @author sqq
 * @since 2024-04-22
 */
@Api(tags = "矿山审批流程")
@RestController
@RequestMapping("/kcl/splc")
@Validated
public class SplcController {

    @Resource
    private ISplcService iSplcService;

    /**
     * 添加矿山审批流程
     */
    @ApiOperation("添加矿山审批流程")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Splc splc) {
        iSplcService.save(splc);
        return CommonResult.ok();
    }

    /**
     * 删除矿山审批流程
     */
    @ApiOperation("删除矿山审批流程")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iSplcService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑矿山审批流程
     */
    @ApiOperation("编辑矿山审批流程")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Splc splc) {
        iSplcService.updateSplc(splc);
        return CommonResult.ok();
    }

    /**
     * 矿山审批流程分页查询
     */
    @ApiOperation("矿山审批流程分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Splc>> page() {
        return CommonResult.data(iSplcService.page(new Splc()));
    }


    /**
     * 审批流程分页
     */
    @ApiOperation("审批流程分页")
    @GetMapping("/pageSplcVo")
    public CommonResult<Page<SplcVo>> pageSplcVo(
            @ApiParam(name = "current", value = "页数", example = "1", required = true)  @RequestParam long current,
            @ApiParam(name = "size", value = "每页数量", example = "20", required = true) @RequestParam long size,
            @ApiParam(name = "nd", value = "年度")  Integer nd,
            @ApiParam(name = "xzqh", value = "行政区划")  String xzqh,
            @ApiParam(name = "djlx", value = "登记类型（0全部 1新立 2变更 3延续 4注销 5转让）") @RequestParam Integer djlx
    ) {
        return CommonResult.data(iSplcService.pageSplcVo(current,size,nd,xzqh,djlx));
    }



}
